package com.ymatou.iapi.couponmanage.compare;

import java.io.File;
import java.util.Arrays;

import org.json.JSONArray;

import com.ymatou.iapi.couponmanage.compare.bean.CheckCouponExistsResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetApplyProductsResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetBatchInfoResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetConversionBillByBatchResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetConversionBillInfoResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetConversionCodeGenerateStatusResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetConversionCodesByPagingResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetCouponInfoesByCodeResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetCouponsOfBatchByPagingResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetPlatformBatchesByPagingResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetSellerBatchCountInCurrentMonthResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetSellerBatchesByPagingResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetSellerBatchesForAppResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetSellerReceiveBatchesResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetSellerValidBatchCountResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetSellerValidBatchResp;
import com.ymatou.iapi.couponmanage.compare.bean.GetUserCouponInfoesByPagingResp;
import com.ymt.core.tool.Logger;
import com.ymttest.utils.MapUtil;
import com.ymttest.utils.compare.CompareManager;

public class MainCompare {
	public final static String couponFolder = System.getProperty("user.dir") + File.separator + "resource" + File.separator
			+ "CompareData" + File.separator + "coupon" + File.separator;
	
	
	public final static boolean isIgnoreInfo = false;
	
	public static void compareQueryValidBatchList() {
		String paramsFilePath = couponFolder + "sellerId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("SellerId",x[0],"PageIndex",1,"PageSize",5000), 
										CouponManagerCompareAPI.old_QueryValidBatchListAPI,
										CouponManagerCompareAPI.QueryValidBatchListAPI,
										GetSellerValidBatchResp.class,
										"data");
		
	}

	public static void compareQueryValidCouponCount() {
		String paramsFilePath = couponFolder + "sellerId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("SellerId",x[0]), 
										CouponManagerCompareAPI.old_QueryValidCouponCountAPI,
										CouponManagerCompareAPI.QueryValidCouponCountAPI,
										GetSellerValidBatchCountResp.class,
										"data");
		
	}
	
	public static void compareGetSellerReceiveBatches() {
		String paramsFilePath = couponFolder + "sellerId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("SellerId",Integer.parseInt(x[0]),"EffectiveStartTime","2018-03-11T15:55:35.4549606+08:00",
																		"EffectiveEndTime","2018-03-12T15:55:35.4549606+08:00"), 
										CouponManagerCompareAPI.old_GetSellerReceiveBatchesAPI,
										CouponManagerCompareAPI.GetSellerReceiveBatchesAPI,
										GetSellerReceiveBatchesResp.class,
										"data");
		
	}
	
	public static void compareGetSellerBatchesByPaging() {
		String paramsFilePath = couponFolder + "sellerId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("SellerId",x[0],"EffectiveStartTime","2018-03-11T15:55:35.4549606+08:00",
																		   "EffectiveEndTime", "2019-03-12T15:55:35.4549606+08:00",
																		   "BatchStatus",-1,
																		   "PageIndex",1,
																		   "PageSize",10000,
																		   "CouponType",0), 
										CouponManagerCompareAPI.old_GetSellerBatchesByPagingAPI,
										CouponManagerCompareAPI.GetSellerBatchesByPagingAPI,
										GetSellerBatchesByPagingResp.class,
										"data");
		
	}
	
	public static void compareGetSellerBatchCountInCurrentMonth() {
		String paramsFilePath = couponFolder + "sellerId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("SellerId",x[0]), 
										CouponManagerCompareAPI.old_GetSellerBatchCountInCurrentMonthAPI,
										CouponManagerCompareAPI.GetSellerBatchCountInCurrentMonthAPI,
										GetSellerBatchCountInCurrentMonthResp.class,
										"data");
		
	}
	
	public static void compareGetSellerBatchesForApp() {
		String paramsFilePath = couponFolder + "sellerId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("SellerId",x[0],
												   "BatchStatus",-1,
												   "PageIndex",1,
												   "PageSize",10000),  
										CouponManagerCompareAPI.old_GetSellerBatchesForAppAPI,
										CouponManagerCompareAPI.GetSellerBatchesForAppAPI,
										GetSellerBatchesForAppResp.class,
										"data");
		
	}
	
	public static void compareGetBatchCount() {
		String paramsFilePath = couponFolder + "sellerId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("SellerId",x[0]),  
										CouponManagerCompareAPI.old_GetBatchCountAPI,
										CouponManagerCompareAPI.GetBatchCountAPI,
										GetSellerBatchesForAppResp.class,
										"data");
		
	}
	
	public static void compareGetBatchInfo() {
		String paramsFilePath = couponFolder + "batchCode.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("BatchCode",x[0]),  
										CouponManagerCompareAPI.old_GetBatchInfoAPI,
										CouponManagerCompareAPI.GetBatchInfoAPI,
										GetBatchInfoResp.class,
										"data");
		
	}
	
	public static void compareGetPlatformBatchesByPaging() {
		String paramsFilePath = couponFolder + "empty.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("PageIndex",1,"PageSize",10000,"SendType",-1,"AcquireCouponMethod",-1,"ProductLimitType",-1,"CreateTimeStart","2016-01-1T18:14:11.2929606+08:00"),  
										CouponManagerCompareAPI.old_GetPlatformBatchesByPagingAPI,
										CouponManagerCompareAPI.GetPlatformBatchesByPagingAPI,
										GetPlatformBatchesByPagingResp.class,
										"data");
		
	}
	
	public static void compareGetApplyProducts() {
		String paramsFilePath = couponFolder + "batchId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("BatchId",x[0]),  
										CouponManagerCompareAPI.old_GetApplyProductsAPI,
										CouponManagerCompareAPI.GetApplyProductsAPI,
										GetApplyProductsResp.class,
										"data");
		
	}
	
	public static void compareGetCouponInfoesByCode() {
		String paramsFilePath = couponFolder + "couponCode.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("CouponCodes",new JSONArray(Arrays.asList(x[0]))),  
										CouponManagerCompareAPI.old_GetCouponInfoesByCodeAPI,
										CouponManagerCompareAPI.GetCouponInfoesByCodeAPI,
										GetCouponInfoesByCodeResp.class,
										"data");
	}
	
	public static void compareGetUserCouponInfoesByPaging() {
		String paramsFilePath = couponFolder + "userId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("UserId",x[0],
												"GetStartTime", "2018-03-01T11:21:52.1014982+08:00",
												"GetEndTime", "2018-03-13T11:21:52.1014982+08:00",
												 "CreaterType",0,
												 "PageIndex",1,
												 "PageSize",10000),  
										CouponManagerCompareAPI.old_GetUserCouponInfoesByPagingAPI,
										CouponManagerCompareAPI.GetUserCouponInfoesByPagingAPI,
										GetUserCouponInfoesByPagingResp.class,
										"data");
	}
	
	public static void compareCheckCouponExists() {
		String paramsFilePath = couponFolder + "couponCode.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("CouponCode",x[0]),  
										CouponManagerCompareAPI.old_CheckCouponExistsAPI,
										CouponManagerCompareAPI.CheckCouponExistsAPI,
										CheckCouponExistsResp.class,
										"data");
	}
	
	public static void compareGetCouponsOfBatchByPaging() {
		String paramsFilePath = couponFolder + "batchId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("BatchId",x[0],"PageSize",10000,"PageIndex",1),  
										CouponManagerCompareAPI.old_GetCouponsOfBatchByPagingAPI,
										CouponManagerCompareAPI.GetCouponsOfBatchByPagingAPI,
										GetCouponsOfBatchByPagingResp.class,
										"data");
	}
	
	
	public static void compareGetById() {
		String paramsFilePath = couponFolder + "conversionBillId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("ConversionBillId",x[0]),  
										CouponManagerCompareAPI.old_GetByIdAPI,
										CouponManagerCompareAPI.GetByIdAPI,
										GetConversionBillInfoResp.class,
										"data");
	}
	
	
	public static void compareGetGenerateStatus() {
		String paramsFilePath = couponFolder + "conversionBillId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("ConversionBillId",x[0]),  
										CouponManagerCompareAPI.old_GetGenerateStatusAPI,
										CouponManagerCompareAPI.GetGenerateStatusAPI,
										GetConversionCodeGenerateStatusResp.class,
										"data");
	}
	
	public static void compareGetConversionCodesByPaging() {
		String paramsFilePath = couponFolder + "conversionBillId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("ConversionBillId",x[0],"PageSize",1000,"PageIndex",1),  
										CouponManagerCompareAPI.old_GetConversionCodesByPagingAPI,
										CouponManagerCompareAPI.GetConversionCodesByPagingAPI,
										GetConversionCodesByPagingResp.class,
										"data");
	}
	
	
	
	public static void compareGetIdByBatch() {
		String paramsFilePath = couponFolder + "CouponBatchCode.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										isIgnoreInfo,
										x->MapUtil.hashMap("batchCode",x[0]),  
										CouponManagerCompareAPI.old_GetIdByBatchAPI,
										CouponManagerCompareAPI.GetIdByBatchAPI,
										GetConversionBillByBatchResp.class,
										"data");
	}
	 
	
	public static void main(String args[]){
		Logger.setDebug(false);
		
		String num="18";
		
		
		
		if (args.length>0){
			num = args[0];
		}
		
		System.out.println(num);
		
		if (num.equals("1")){
			compareQueryValidBatchList();
			
		}else if (num.equals("2")){
			compareQueryValidCouponCount();
			
		}else if (num.equals("3")){
			compareGetSellerReceiveBatches();
			
		}else if (num.equals("4")){
			compareGetSellerBatchesByPaging();
			
		}else if (num.equals("5")){
			compareGetSellerBatchCountInCurrentMonth();
			
		}else if (num.equals("6")){
			compareGetSellerBatchesForApp();
			
		}else if (num.equals("7")){
			compareGetBatchCount();
			
		}else if (num.equals("8")){
			compareGetBatchInfo();
			
		}else if (num.equals("9")){
			compareGetPlatformBatchesByPaging();
			
		}else if (num.equals("10")){
			compareGetApplyProducts();
			
		}else if (num.equals("11")){
			compareGetCouponInfoesByCode();
			
		}else if (num.equals("12")){
			compareGetUserCouponInfoesByPaging();
			
		}else if (num.equals("13")){
			compareCheckCouponExists();
			
		}else if (num.equals("14")){
			compareGetCouponsOfBatchByPaging();
			
		}else if (num.equals("15")){
			compareGetById();
			
		}else if (num.equals("16")){
			compareGetGenerateStatus();
			
		}else if (num.equals("17")){
			compareGetConversionCodesByPaging();
			
		}else if (num.equals("18")){
			compareGetIdByBatch();
			
		}
		
		
		
		
		
		
	
		
		
		
	}
	
	
}
